|
class Layers |
|
Parent: Entity |
|
|
| |
|
Sample Code:layerstests.rb |
|
|
Instance Methods |
|
[] |
|
The [] method is used to retrieve a layer by index or name |
|
Syntax: |
|
layer = layers[index] layer = layers["name"] |
|
Arguments: |
|
index - a number representing the layer's index in an array of Layer objects "name" - the name of the layer |
|
Return Value: |
|
layer - a Layer object |
|
Comments: |
|
|
|
Example: |
|
model = Sketchup.active_model |
|
add |
|
The add method is used to add a new layer. |
|
Syntax: |
|
layer = layers.add("layer name") |
|
Arguments: |
|
"layer name" - the name of the added layer |
|
Return Value: |
|
layer - the new Layer object |
|
Comments: |
|
If you give the name of a Layer that is already defined, it will return the existing Layer rather than adding a new one. |
|
Example: |
|
model = Sketchup.active_model |
|
at |
|
The at method is an alias for []. See []. |
|
Syntax: |
|
|
|
Arguments: |
|
|
|
Return Value: |
|
|
|
Comments: |
|
|
|
Example: |
|
|
|
count |
|
The count method is an alias for length. See length. |
|
Syntax: |
|
count = layers.count |
|
Arguments: |
|
|
|
Return Value: |
|
|
|
Comments: |
|
|
|
Example: |
|
|
|
each |
|
The each method is used to iterate through all of the layers. |
|
Syntax: |
|
layers.each {|layer| ...} |
|
Arguments: |
|
|
|
Return Value: |
|
layer - a variable that will hold each Layer object as they are found. |
|
Comments: |
|
|
|
Example: |
|
model = Sketchup.active_model |
|
length |
|
The length method retrieves the number of layers. |
|
Syntax: |
|
length = layers.length |
|
Arguments: |
|
|
|
Return Value: |
|
length - the number of entities in the collection of entities if successful |
|
Comments: |
|
|
|
Example: |
|
model = Sketchup.active_model |
|
unique_name |
|
The unique_name method generates a unique layer name. |
|
Syntax: |
|
newname = layers.unique_name <basename> |
|
Arguments: |
|
<basename> - (optional) basename used as part of the generated name |
|
Return Value: |
|
newname - the new layer name |
|
Comments: |
|
With no arguments it generates a new unique name using the default base. With a basename String passed in, it will generate a new unique name that uses the given base as a prefix. For example you could get a Layer name that starts with the string "Walls" with the command: name = layers.unique_name "Walls". You could then use this new unique name to add a new Layer. |
|
Example: |
|
model = Sketchup.active_model |